<template>
  <div class>
    <!--面包屑-->
    <Breadcrumb :Breadcrumb="Breadcrumb"></Breadcrumb>
    <div class="top" v-if="number=1">
      <div class="left"></div>
      <div class="center">{{infoData.title}}</div>
      <div class="right"></div>
    </div>
    <div class="topBox" v-else>
      <h2>任务信息</h2>
      <div class="title">
        <h3>公司汇报任务时的汇报主题展示</h3>
        <span>汇报时间 :</span>
        <span>2019-10-11 12:30:26</span>
      </div>
    </div>
    <div class="banner" v-html='infoData.content'>
    </div>

    <!-- 问题清单附件 -->
    <div class="item_wrap">
      <div class="title_wrap hasbutton">
        <div class="left">
          <div class="line"></div>
          <div class="title">问题清单附件</div>
        </div>
      </div>
      <div v-if="fileList.length == 0" class="note">暂无附件</div>
      <div v-else class="fileList">
        <div class='fileItem' v-for="(item, index) in fileList" :key="index">
            <div :class='item.type'></div>
            <div class='right'>
              <div class='title' :title='item.name'>{{item.name}}</div>
              <div class='fileOpt'>
                <div class='fileSize'>{{(item.size / 1024 / 1024).toFixed(2) + "M"}}</div>
                <div class='optBtn'>
                  <div class='btnOne' @click='view(index)'>
                    <div class='oneImg'></div>
                    <div class='oneTxt'>预览</div>
                  </div>
                  <div class="done">|</div>
                  <div class='btnTwo' @click='upload(index)'>
                    <div class='twoImg'></div>
                    <div class='twoTxt'>下载</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
      </div>
    </div>
    <!-- 问题清单附件 -->
  </div>
</template>
<script>
//面包靴
import Breadcrumb from "@/components/IncorruptibleArchives/Breadcrumb.vue";
// import BaiduMap from "vue-baidu-map/components/map/Map.vue";
export default {
  components: {
    Breadcrumb,
    // BaiduMap,
  },
  data() {
    return {
      infoData:{},
      fileList: [],
      number: "",
      //面包靴跳转数据
      Breadcrumb: [
        {
          name: "廉政档案",
          link: "IncorruptibleArchives",
        },
        {
          name: "公司档案",
          link: "archives",
        },
        {
          name: "公司档案详情",
          link: "Detail",
        },
        {
          name: "新增档案列表",
          link: "AddArchives",
        },
      ],
    };
  },
  mounted() {
    this.get()
    this.getInfo()
  },
  methods: {
    get(){
      let number = this.$route.query.number;
      if(number==1){
        this.Breadcrumb=[
          {
            name: "廉政档案",
            link: "/index/IncorruptibleArchives",
          },
          {
            name: "公司档案",
            link: "/index/IncorruptibleArchives/archives",
          },
          {
            name: "公司档案详情",
            link: "/index/IncorruptibleArchives/archives/Detail",
          },
          {
            name: "档案列表更多",
            link: "/index/IncorruptibleArchives/archives/ArchivesMore",
          },
          {
            name: "查看档案",
            link: "/index/IncorruptibleArchives/archives/Look",
          },
        ]
      }
    },
    getInfo(){
      let paramsJson ={
        id: this.$route.query.id
      }
      this.Api.archiveDetail(paramsJson).then((res) => {
        if (res.code == 0) {
          this.infoData = res.data
          this.fileList = res.data.attachList.map(item => {
            let testmsg = item.name.substring(item.name.lastIndexOf('.') + 1).toLowerCase()
            let type = '';
            switch(testmsg){
              case 'pdf':
                type = 'leftPdf'
                break;
              case 'ppt':
                type = 'leftPpt'
                break;
              case 'mp4':
                type = 'leftMp4'
                break;
              case 'avi':
                type = 'leftAvi'
                break;
              case 'jpg':
                type = 'leftImg'
                break;
              case 'png':
                type = 'leftImg'
                break;
              case 'jpeg':
                type = 'leftImg'
                break;
            }
            item.type = type
            return item
          })
        }
      })
    },
    view(index){
      this.fileUrl = this.fileList[index].url
      this.baseUrl = this.$store.state.PortalManagement.fileIp
      this.fileUrl = this.baseUrl + this.fileList[index].url
      window.open(this.fileUrl)
    },
    upload(index){
      this.fileUrl = this.fileList[index].url;
      this.Api.download(this.fileUrl).then((res) => {
        let url = window.URL.createObjectURL(new Blob([res],{ type:'text/plain'}))
        let link = document.createElement('a')
        link.style.display = 'none'
        link.href = url
        link.setAttribute('download',this.fileList[index].name)
        document.body.appendChild(link)
        link.click()
      })
    },
  },
};
</script>

<style lang="less" scoped>
.banner {
  width: 100%;
  min-height: 500px;
  background: white;
  padding: 33px 40px;
  box-sizing: border-box;
}
.pic {
  width: 100px;
  height: 100px;
}
.pic img {
  width: 100px;
  height: 100px;
}
.companyName h3 {
  font-size: 30px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: rgba(51, 51, 51, 1);
  line-height: 30px;
  margin: 20px 0;
}
.box1 {
  margin-top: 20px;
  display: flex;
}
.text {
  width: 1418px;
  height: 100px;
}
.a {
  width: 80px;
  font-size: 14px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: rgba(51, 51, 51, 1);
  line-height: 36px;
}

h2 {
  font-size: 16px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 600;
  color: rgba(51, 51, 51, 1);
  line-height: 16px;
  border-left: 4px solid #3d7fff;
  padding: 0 0 0 10px;
  margin-bottom: 39px;
}
.item_wrap {
  background-color: #fff;
  padding: 20px;
  margin-bottom: 10px;
  margin-top: 20px;

  .title_wrap {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    .line {
      width: 4px;
      height: 14px;
      background: #3d7fff;
    }
    .title {
      font-weight: 500;
      margin: 0 10px;
      font-size: 16px;
      color: #333;
    }
  }
  .content_wrap {
    display: flex;
    .item {
      display: flex;
      align-items: center;
      margin-right: 60px;
      .name {
        font-style: 14px;
        font-weight: 500;
        color: #333;
        margin-right: 10px;
      }
      .el-select,
      .el-input {
        width: 320px;
        // height: 36px;
      }
    }
  }
}
.hasbutton {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .left {
    display: flex;
    align-items: center;
  }
  .el-button {
    width: 70px;
    height: 30px;
    padding: 0;
    border: 1px solid rgba(61, 127, 255, 1);
    border-radius: 4px;
    text-align: center;
    line-height: 30px;
    color: #3d7fff;
  }
}
.note {
  font-size: 14px;
  color: #999;
}
.classInput {
  /deep/.el-input__inner {
    text-align: center;
  }
}
.done {
  margin: 0 10px;
}
.time {
  display: flex;
  align-items: center;
}

.button_wrap {
  background-color: #fff;
  position: fixed;
  bottom: 0;
  left: 100px;
  right: 0;
  z-index: 99;
  text-align: right;
  padding: 10px 20px;
  .el-button {
    margin-left: 10px;
  }
}
.fileList {
  overflow: hidden;
  .fileItem{
    float: left;
    width: 360px;
    height: 80px;
    border-radius: 4px;
    border: 1px solid rgba(221, 221, 221, 1);
    margin-right: 20px;
    margin-bottom: 20px;
    padding: 15px;
    display: flex;
    .leftPdf{
      width: 50px;
      height: 50px;
      background:url(../../../../assets/image/pdf.png) no-repeat;
      background-size: 100%;
    }
    .leftImg{
      width: 50px;
      height: 50px;
      background:url(../../../../assets/image/file_img.png) no-repeat;
      background-size: 100%;
    }
    .leftPpt{
      width: 50px;
      height: 50px;
      background:url(../../../../assets/image/file_ppt.png) no-repeat;
      background-size: 100%;
    }
    .leftMp4{
      width: 50px;
      height: 50px;
      background:url(../../../../assets/image/file_video.png) no-repeat;
      background-size: 100%;
    }
    .leftAvi{
      width: 50px;
      height: 50px;
      background:url(../../../../assets/image/file_music.png) no-repeat;
      background-size: 100%;
    }
    .right{
      margin-left: 15px;
      width: 244px;
      height: 50px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      font-size: 14px;
      .title {
        font-size: 16px;
        color: #333;
        white-space:nowrap;
        overflow:hidden;
        text-overflow:ellipsis;
        margin-bottom: 10px;
      }
      .fileOpt{
        display: flex;
        justify-content: space-between;
        .fileSize{
          color: #999;
        }
        .optBtn{
          display: flex;
          justify-content: space-around;
          color: #3d7fff;
          .btnOne{
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            .oneImg{
              margin-right: 2px;
              width: 16px;
              height: 12px;
              background:url(../../../../assets/image/preview.png) no-repeat;
              background-size: contain;
            }
          }
          .btnTwo{
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            .twoImg{
              margin-right: 2px;
              width: 16px;
              height: 12px;
              background:url(../../../../assets/image/download.png) no-repeat;
              background-size: contain;
            }
          }
        }
      }
    }
  }
}
.top {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 95px;
  margin-bottom: 27px;
}
.top .left {
  width: 30px;
  height: 1px;
  background: rgba(51, 51, 51, 1);
}
.top .center {
  height: 30px;
  font-size: 22px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: rgba(51, 51, 51, 1);
  line-height: 30px;
  margin: 0 5px;
}
.top .right {
  width: 30px;
  height: 1px;
  background: rgba(51, 51, 51, 1);
}
.banner p {
  text-indent: 2em;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(51, 51, 51, 1);
  line-height: 26px;
}

.topBox .title {
  width: 100%;
  text-align: center;
  margin: 20px 0px 0px;
}
.title h3 {
  font-size: 26px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: rgba(51, 51, 51, 1);
  line-height: 37px;
}
.title span {
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(102, 102, 102, 1);
  line-height: 22px;
}
.topBox {
  padding: 20px;
  width: 100%;
  background: white;
  box-sizing: border-box;
}
</style>